'''
需求：
1 士兵有一把AK47
2 士兵可以开火射击，射击时需要扣动扳机
3 给枪装上子弹才能发射
4 枪可以发射子弹
'''


class Soldier:
    name = ''
    age = 0

    def __init__(self, name, age):
        self.name = name
        self.age = age

    def shoot(self):
        return self.name + '扣动了扳机，开了一枪'


class Gun:
    model = ''
    bullet = 0

    def __init__(self, model, bullet):
        self.model = model
        self.bullet = bullet

    def check_bullet(self):
        print('还有' +str (self.bullet) + '颗子弹')

def main():
    gun = Gun('Ak47', 25)
    print('枪的型号：' + gun.model, '子弹数：' + str(gun.bullet))
    solider = Soldier('奥摩', 20)
    msg = input("请选择你所需的射击方式：\n1.单发射击\n2。连续射击\n")
    if msg == '1':
        print(solider.shoot())
        gun.bullet=gun.bullet - 1
        gun.check_bullet()
    elif msg == '2':
        while gun.bullet > 0:
            print(solider.shoot())
            gun.bullet = gun.bullet - 1
            gun.check_bullet()


if __name__ == '__main__':
    main()
